class DigitalHumanScene:
    """数字人场景管理"""

    def __init__(self, generator: DigitalHumanGenerator):
        self.generator = generator
        self.scenes = {
            "presentation": {
                "avatar": "professional",
                "background": "office",
                "gesture_level": "high",
                "expression": "confident"
            },
            "education": {
                "avatar": "friendly",
                "background": "classroom",
                "gesture_level": "medium",
                "expression": "patient"
            },
            "entertainment": {
                "avatar": "energetic",
                "background": "colorful",
                "gesture_level": "high",
                "expression": "happy"
            },
            "customer_service": {
                "avatar": "professional",
                "background": "neutral",
                "gesture_level": "low",
                "expression": "neutral"
            }
        }

    def create_scene_video(self,
                           scene_type: str,
                           script: str,
                           custom_config: Optional[Dict] = None) -> Dict:
        """根据场景类型创建数字人视频"""
        scene_config = self.scenes.get(scene_type, self.scenes["presentation"])

        if custom_config:
            scene_config.update(custom_config)

        # 根据场景调整脚本语气
        formatted_script = self._format_script_by_scene(script, scene_type)

        return self.generator.create_talking_head(
            text=formatted_script,
            avatar_id=scene_config["avatar"],
            **{k: v for k, v in scene_config.items() if k != "avatar"}
        )

    def _format_script_by_scene(self, script: str, scene_type: str) -> str:
        """根据场景格式化脚本"""
        if scene_type == "presentation":
            return f"大家好，{script}"
        elif scene_type == "education":
            return f"同学们，今天我们来学习：{script}"
        elif scene_type == "entertainment":
            return f"嘿！{script}"
        elif scene_type == "customer_service":
            return f"您好，{script}"
        return script

    def batch_create_scenes(self, scripts: Dict[str, str]) -> Dict[str, Dict]:
        """批量创建不同场景的视频"""
        results = {}
        for scene_type, script in scripts.items():
            results[scene_type] = self.create_scene_video(scene_type, script)
        return results